package com.dempsey.api.factory;

import com.dempsey.api.RemoteGoodService;
import com.dempsey.api.RemoteUserService;
import com.dempsey.api.domain.User;
import com.dempsey.common.core.domain.AjaxResult;
import com.dempsey.common.core.domain.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 商品服务降级处理
 *
 * @author Dempsey
 */
@Component
public class RemoteGoodFallbackFactory implements FallbackFactory<RemoteGoodService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteGoodFallbackFactory.class);

    @Override
    public RemoteGoodService create(Throwable throwable) {
        log.error("用户服务调用失败:{}", throwable.getMessage());
        return new RemoteGoodService() {

            @Override
            public R<Integer> getStock(int goodId) {
                return null;
            }

            @Override
            public AjaxResult delStock(int goodId) {
                return null;
            }
        };
    }
}
